<?php
/*
 * @Author: 乔
 * @Date: 2021-11-02 09:17:31
 * @LastEditTime: 2021-11-03 15:44:56
 * @LastEditors: 乔
 * @FilePath: \tp30\app\admin\model\Admin.php
 */

namespace app\admin\model;

use think\Model;

class Admin extends BaseModel
{
    // protected $table = 'table_name';
    // protected $pk = 'id';
    public function searchNameAttr($q, $v, $d)
    {
        $q->where('name', '=', "{$v}");
    }
    public function searchEmailAttr($q, $v, $d)
    {
        $v = strtolower($v);
        $q->where('email', '=', "{$v}");
    }
    public function searchPwdAttr($q, $v, $d)
    {
        $q->where('pwd', '=', "{$v}");
    }
    public static function getAdminList()
    {
        $list = Admin::field('id,name,headimg,')
            ->paginate([
                'list_rows' => 5,
            ]);
        return $list;
    }
    public static function findAdminList($where)
    {
        $list = Admin::withSearch(array_keys($where), $where)
            ->find();
        return $list;
    }
}
